package de.riceman.simpleGo.view.forms;

import java.util.ArrayList;

import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import org.springframework.binding.form.FormModel;
import org.springframework.richclient.application.Application;
import org.springframework.richclient.form.AbstractForm;
import org.springframework.richclient.form.binding.swing.SwingBindingFactory;
import org.springframework.richclient.form.builder.TableFormBuilder;

import de.riceman.simpleGo.events.SimpleGoLifecycleApplicationEvent;
import de.riceman.simpleGo.main.NewGameSetup;

public class NewGameForm extends AbstractForm {

	static NewGameSetup newGameSetup = new NewGameSetup();

	ArrayList<String> playerTypes;
	ArrayList<String> gameSizeTypes;
	ArrayList<String> playerStrengthValues;

	public NewGameForm(FormModel model) {
		super(model, "newGameForm");
	}
	
	public JComponent createFormControl() {
		
		playerTypes = new ArrayList<String>();
		playerTypes.add("Human via CLI");
		playerTypes.add("DamnStupid AI");
		playerTypes.add("FirstSimpleAI");
		playerTypes.add("MonteCarloSimpleAI");
		
		gameSizeTypes = new ArrayList<String>();
		gameSizeTypes.add("5");
		gameSizeTypes.add("9");
		gameSizeTypes.add("13");
		gameSizeTypes.add("19");
		
		playerStrengthValues = new ArrayList<String>();
		playerStrengthValues.add("10");
		playerStrengthValues.add("50");
		playerStrengthValues.add("100");
		playerStrengthValues.add("150");
		playerStrengthValues.add("200");
		playerStrengthValues.add("250");
		playerStrengthValues.add("300");
		
		SwingBindingFactory bindingFactory = (SwingBindingFactory) getBindingFactory(); 
		
		TableFormBuilder builder = new TableFormBuilder(getBindingFactory());
		builder.add("darkPlayersName");
		builder.row();
		builder.add("lightPlayersName");
		builder.row();
		builder.add(bindingFactory.createBoundComboBox("darkPlayersType", playerTypes));
		builder.row();
		builder.add(bindingFactory.createBoundComboBox("darkPlayersStrength", playerStrengthValues));
		builder.row();
		builder.add(bindingFactory.createBoundComboBox("lightPlayersType", playerTypes));
		builder.row();
		builder.add(bindingFactory.createBoundComboBox("lightPlayersStrength", playerStrengthValues));
		builder.row();
		builder.add(bindingFactory.createBoundComboBox("gameSize", gameSizeTypes));
		builder.row();
		builder.add("continuous");
		builder.row();
		JPanel panel = (JPanel) builder.getForm();
		panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

		return panel;
	}
	
	/**
	 * @return the gameSizeTypes
	 */
	public ArrayList<String> getGameSizeTypes() {
		return gameSizeTypes;
	}

	/**
	 * @param gameSizeTypes the gameSizeTypes to set
	 */
	public void setGameSizeTypes(ArrayList<String> gameSizeTypes) {
		this.gameSizeTypes = gameSizeTypes;
	}

	/**
	 * @return the playerTypes
	 */
	public ArrayList<String> getPlayerTypes() {
		return playerTypes;
	}

	/**
	 * @param playerTypes the playerTypes to set
	 */
	public void setPlayerTypes(ArrayList<String> playerTypes) {
		this.playerTypes = playerTypes;
	}
 
}